<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<%@ taglib prefix="his_fns" uri="/WEB-INF/tlds/his_fns.tld" %>

<div class="content-wrap">
    <div class="wrapper">
        <section class="panel panel-default" style="height: 97%">
            <div class="panel-body height-100">
                <div class="col-lg-3 height-100">
                    <div class="div_title">
                        <div class="green">
                            <div class="green-01">病人列表</div>
                        </div>
                    </div>
                    <fieldset class="height-100">
                            <form:form id="searchFormDict" modelAttribute="bloodMatch" onsubmit="return loadDivForm('mainCenterDiv','searchFormDict','${ctx}/blood/bloodMatch/index');"
                                       method="post" class="form-inline">
                            <label class="pull-left">开始时间：</label>
                            <div class="col-sm-8"><input id="startDateId" name="startDate" onFocus="var endDateId=$dp.$('endDateId');WdatePicker({onpicked:function(){endDateId.focus();},
                            maxDate:'#F{$dp.$D(\'endDateId\')}'})" readonly class="form-control Wdate" value="<fmt:formatDate value="${bloodMatch.startDate}" pattern="yyyy-MM-dd" />"/></div>
                            <label class="pull-left">结束时间：</label>
                            <div class="col-sm-8 mt5"><input id="endDateId" name="stopDate" onFocus="WdatePicker({minDate:'#F{$dp.$D(\'startDateId\')}'})"  readonly class="form-control Wdate"
                                                             value="<fmt:formatDate value="${bloodMatch.stopDate}" pattern="yyyy-MM-dd" />" /></div>
                            <div class="pull-right mt5 mr10 mb5">
                                <button class="btn btn-primary" id="getApplyNum" type="submit">查询</button>
                            </div>
                        </form:form>
                        <table id="applyTable" class="table table-bordered mg-t datatable">
                            <thead>
                              <tr>
                                  <th>申请单</th>
                                  <th>姓名</th>
                              </tr>
                            </thead>
                            <tbody>
                            <c:forEach items="${list}" var="d">
                                <tr onclick="loadBloodCapacity('${d.applyNum}')">
                                    <td>${d.applyNum}</td>
                                    <td>${d.patientName}</td>
                                </tr>
                            </c:forEach>
                            </tbody>
                        </table>
                    </fieldset>
                </div>
                <form:form id="saveBloodMatch" data-parsley-validate="" modelAttribute="bloodMatch"
                onsubmit="return formSaveLoad('mainCenterDiv','saveBloodMatch','${ctx}/blood/bloodMatch/save','${ctx}/blood/bloodMatch/index');" method="post" class="form-horizontal">
                <div class="col-lg-9 height-100">
                    <div class="col-lg-12 p0">
                        <div class="div_title">
                            <div class="green">
                                <div class="green-01">基本信息</div>
                            </div>
                        </div>
                        <fieldset>
                        <form class="form-horizontal">
                            <div class="col-lg-3">
                                <div class="form-group m0">
                                    <label class="col-lg-5 p0 control-label">住   院   号：</label>
                                    <div class="col-lg-7 p0">
                                        <label class="usual_label" id="visitNo"></label>
                                    </div>
                                </div>
                                <div class="form-group m0">
                                    <label class="col-lg-5 p0 control-label">所在科室：</label>
                                    <div class="col-lg-7 p0">
                                        <label class="usual_label" id="appDept"></label>
                                    </div>
                                </div>
                                <div class="form-group m0">
                                    <label class="col-lg-5 p0 control-label">申请日期：</label>
                                    <div class="col-lg-7 p0">
                                        <label class="usual_label" id="createDate"></label>
                                    </div>
                                </div>
                            </div>
                            <div class="col-lg-3">
                                <div class="form-group m0">
                                    <label class="col-lg-5 p0 control-label">姓名：</label>
                                    <div class="col-lg-7 p0">
                                        <label class="usual_label" id="patientName"></label>
                                    </div>
                                </div>
                                <div class="form-group m0">
                                    <label class="col-lg-5 p0 control-label">血型：</label>
                                    <div class="col-lg-7 p0">
                                        <label class="usual_label" id="patBloodGroup"></label>
                                    </div>
                                </div>
                                <div class="form-group m0">
                                    <label class="col-lg-5 p0 control-label">开单医生：</label>
                                    <div class="col-lg-7 p0">
                                        <label class="usual_label" id="appDoctorName"></label>
                                    </div>
                                </div>
                            </div>
                            <div class="col-lg-3">
                                <div class="form-group m0">
                                    <label class="col-lg-3 p0 control-label">性别：</label>
                                    <div class="col-lg-3 p0">
                                        <label class="usual_label" id="sex"></label>
                                    </div>
                                    <label class="col-lg-3 p0 control-label">年龄：</label>
                                    <div class="col-lg-3 p0">
                                        <label class="usual_label" id="age"></label>
                                    </div>
                                </div>
                                <div class="form-group m0">
                                    <label class="col-lg-3 p0 control-label">RH：</label>
                                    <div class="col-lg-3 p0">
                                        <label class="usual_label" id="rh"></label>
                                    </div>
                                    <label class="col-lg-3 p0 control-label">费别：</label>
                                    <div class="col-lg-3 p0">
                                        <label class="usual_label" id="chargeType"></label>
                                    </div>
                                </div>
                                <div class="form-group m0">
                                    <label class="col-lg-3 p0 control-label">用血方式：</label>
                                    <div class="col-lg-9 p0">
                                        <label class="usual_label" id="fastSlow"></label>
                                    </div>
                                </div>
                            </div>
                            <div class="col-lg-3">
                                <button class="btn btn-primary" type="submit">保存</button>
                            </div>
                        </form>
                    </fieldset>
                    </div>
                    <div class="col-lg-6 p0">
                        <div class="div_title">
                            <div class="green">
                                <div class="green-01">血液需求</div>
                            </div>
                        </div>
                        <fieldset class="height-170 overflow-auto">
                            <table class="table table-bordered mg-t datatable">
                                <thead>
                                <tr>
                                    <th>用血安排</th>
                                    <th>输血量</th>
                                    <th>单位</th>
                                    <th>成分</th>
                                </tr>
                                </thead>
                                <tbody id="bloodRequire"></tbody>
                            </table>
                        </fieldset>
                    </div>
                    <div class="col-lg-6 p0">
                        <div class="div_title">
                            <div class="green">
                                <div class="green-01">血液列表</div>
                            </div>
                        </div>
                        <fieldset class="height-170 overflow-auto">
                            <form:form id="searchForm"  modelAttribute="bloodInpDetail" onsubmit="return loadDivForm('bloodInp','searchForm','${ctx}/blood/bloodMatch/loadBloodStock');"
                                       method="get" class="form-inline">
                                <label>血型：</label>
                                <form:select onchange="reloadInpDetail()" path="patBloodGroup" id="bloodGroup" htmlEscape="false" class="form-control">
                                    <form:option value=""></form:option>
                                    <form:options items="${fns:getDictList('BLOOD_TYPE_DICT')}" itemLabel="label" itemValue="value" htmlEscape="false" />
                                </form:select>
                                <label>成分：</label>
                                <form:select onchange="reloadInpDetail()" path="componentId" id="componentId" htmlEscape="false" class="form-control" >
                                    <form:option value=""></form:option>
                                    <form:options items="${his_fns:getComponentList()}" itemLabel="bloodName" itemValue="id" htmlEscape="false" />
                                </form:select>
                            </form:form>
                            <table class="table table-bordered mg-t datatable">
                                <thead>
                                <tr>
                                    <th>入库单号</th>
                                    <th hidden>ID</th>
                                    <th>血袋号</th>
                                    <th>血液成分</th>
                                    <th>血型</th>
                                    <th>储血量</th>
                                    <th>单位</th>
                                </tr>
                                </thead>
                                <tbody id="bloodInp"></tbody>
                            </table>
                        </fieldset>
                    </div>
                    <div class="col-lg-12 p0">
                        <label>收取配血费：</label>
                        <%--<label class="usual_label">00012</label>--%>
                            <c:forEach items="${bloodMatchDict}" var="mathcPrice">
                                <input type="checkbox" name="matchPriceIds" value="${mathcPrice.id}"> ${mathcPrice.label}
                            </c:forEach>
                        <div class="div_title">
                            <div class="green">
                                <div class="green-01">配血区</div>
                            </div>
                        </div>
                        <fieldset>
                                <table id="contentTable" class="table table-bordered mg-t datatable">
                                    <thead>
                                    <tr>
                                        <th hidden>ID</th>
                                        <th hidden>申请单号</th>
                                        <th>血袋号</th>
                                        <th>血袋血型</th>
                                        <th hidden>血液成分ID</th>
                                        <th>血液成分</th>
                                        <th>失效日期</th>
                                        <th>配血方式</th>
                                        <th>第一配血结果</th>
                                        <th>第一配血人</th>
                                        <th>第二配血结果</th>
                                        <th>第二配血人</th>
                                    </tr>
                                    </thead>
                                    <tbody></tbody>
                                </table>

                        </fieldset>
                    </div>
                </div>
                </form:form>
            </div>
        </section>
    </div>
</div>
<script src="${ctxStatic}/js/blood/bloodMatch.js"></script>
<script type="text/javascript">
    //动态加载血液列表
    function reloadInpDetail() {
        var patBloodGroup = $("#bloodGroup").val();
        var componentId = $("#componentId").val();
        loadDiv('bloodInp', '${ctx}/blood/bloodMatch/loadBloodStock?patBloodGroup=' + patBloodGroup + "&componentId=" + componentId);
    }
</script>
